home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / utils / tweak16b / tweak.doc < prev    next >
Text File  |  1993-11-29  |  43KB  |  1,055 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                 TWEAK 1.6ß - Mold your own VGA modes
  8.  
  9.          by Robert Schmidt of Ztiff Zox Softwear, 1992-93
  10.  
  11.  
  12.           This program and the accompanying source files
  13.               are hereby donated to the public domain.
  14.                   (for whatever that's worth...)
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. (Sorry for not page-formatting this doc.  The headers can be found by
  23. doing a text search with your favourite editor.)
  24.  
  25.  
  26. Contents:
  27.  
  28. WHAT IS TWEAK, ANYWAY?
  29. SUGGESTION BOX
  30. DISCLAIMER
  31. A QUICK PRIMER
  32. WHAT HAS TWEAK GOT TO DO WITH THIS?
  33. A COUPLE OF RULES
  34. A TUTORIAL
  35. EDITOR REFERENCE
  36. FREQUENTLY ASKED QUESTIONS
  37. THE TWEAK FILES
  38. USING TWEAK MODES ON YOUR OWN
  39. THE INCLUDED FILES
  40. THE 'MISC' DIRECTORY
  41. CREDITS
  42. BIBLIOGRAPHY
  43. HOW TO REACH ME
  44.  
  45.  
  46.  
  47.  
  48.                         WHAT IS TWEAK, ANYWAY?
  49.  
  50.  
  51. TWEAK is an utility to ease the work of twiddling with the registers on
  52. a standard VGA compatible video card to produce and explore new, previously
  53. undocumented screen modes with weird resolutions.  You will want to
  54. purchase a technical VGA reference to get the full potential out of
  55. TWEAK, but I included some files to get you started (see the section
  56. on the 'MISC' directory).
  57.  
  58. TWEAK.EXE is the main executable.  This version is not compatible with 
  59. any versions prior to 1.0, so if you want to use files created by 
  60. version 0.9x, convert them with 09TO10.EXE.  
  61.  
  62. Stop press!  In the subdirectory XINTRO is an article which serves as
  63. an introduction to programming in Mode X (320x240 with 256 colors).
  64. Make sure you read this if you're new to tweaking and Mode X!
  65.  
  66. MODES.DOC describes some of the more exciting 256x256, 400x300 
  67. and 400x600 256-color modes!
  68.  
  69.  
  70.  
  71.  
  72.                         SUGGESTION BOX
  73.  
  74.  
  75. All suggestions to enhance or modify TWEAK are welcome, especially bug
  76. reports/fixes.  So are donations, for that matter.  See e-mail and
  77. snail-mail addresses at the end of this file.
  78.  
  79. Please send me any changes you make to enhance TWEAK or to make it
  80. compatible with other compilers or video cards, and I will start
  81. including conditional sections for each supported compiler.
  82. Do *not* re-release the changed source without my permission.
  83. Well, how can I stop ya...?
  84.  
  85. Any suggestions and contributions will be credited in subsequent
  86. versions, although I can't guarantee that your ideas will actually be
  87. used.
  88.  
  89.  
  90.  
  91.  
  92.  
  93.                           DISCLAIMER
  94.  
  95.  
  96. I don't think this is neccessary in PD stuff, but everybody else does
  97. it:
  98.  
  99. The author author of this archive has used his best efforts in 
  100. preparing it.  However, the author makes no warranty of any kind, 
  101. expressed or implied, with regard to the programs, data or 
  102. documentation included with the archive.  The author shall not be 
  103. liable in any event for incidental or consequential damages in 
  104. connection with, or arising out of, the furnishing, performance, 
  105. quality, or use of the programs, data or documentation included in this 
  106. archive.
  107.  
  108. Phew.
  109.  
  110. Some time ago, putting illegal or unsupported values or combinations
  111. of such into the video card registers might prove hazardous to both
  112. your monitor and your health.  I have *never* claimed that bad things
  113. can't happen if you use TWEAK, although I'm pretty sure it never will.
  114. I've never heard of any damage arising from trying out TWEAK, or from
  115. general VGA tweaking in any case.  I did receive a mail from a person
  116. whose monitor failed producing the correct colors, after using mode
  117. X.
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.                            A QUICK PRIMER
  125.  
  126.  
  127. You never heard about neither documented nor undocumented modes, you 
  128. say?  Well, to begin with:  Your VGA card has a number of registers 
  129. that control the way the card works.  That is, how it is going to 
  130. translate the data that programs put into the video memory, to the 
  131. signals that produce text and/or graphics on your monitor.
  132.  
  133. The standard interface to a video card on all IBM compatible PCs is the 
  134. BIOS, which consists of several device independant routines for setting 
  135. screen modes, moving the cursor, writing text, scrolling blocks of text 
  136. etc.  The BIOS also takes care of setting the appropriate registers at 
  137. appropriate times, for example when changing screen modes.  That way, 
  138. programmers have a consistent interface to the VGA, and usually won't 
  139. need to tamper with the registers directly.
  140.  
  141. A screen mode specifies the resolution of the image you see on the 
  142. screen, i.e. the number of pixels (dots) horizontally and vertically, 
  143. the number of colors, and wether the screen should be capable of 
  144. showing just text, or if graphics are allowed.  These things are 
  145. controlled by the VGA registers, and the BIOS contains a number of 
  146. predefined tables of register values for the standard VGA modes we've 
  147. all come to love and honour.  Mode number 3, for example, is the 80 
  148. characters times 25 lines (80x25) text screen that most people use 
  149. daily.  Mode number 19 (or 13h in hexadecimal) is the 256-color 320x200 
  150. mode used in most popular games supporting the VGA.
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.                 WHAT HAS TWEAK GOT TO DO WITH THIS?
  158.  
  159.  
  160. Well, some people, me included, are of the 'power-hungry' breed.  We want
  161. to exploit the full potential of everything we get between our hands.
  162. We think that the one 320x200 256-color mode supported by all standard VGA
  163. BIOS'es is for wimps.  Some guy came up with the idea of modifying the
  164. register configuration, to achieve greater resolution and a different
  165. video memory layout.
  166.  
  167. TWEAK grants you direct access to all the most significant registers
  168. that control such things as resolution and colors.  You may have thought
  169. that your VGA was limited to 320x200 when it was displaying 256 colors?
  170. Well, all VGAs are able to support no less than 400x600 in 256 colors.
  171. (The problem is with the monitors, which might not be sophisticated
  172. enough to support the relatively much higher clock frequency needed to
  173. output that many pixels.  My monitor flickers and rolls occasionaly.)
  174.  
  175. Most newer VGA cards' BIOSes add several enhanced modes not supported
  176. by the standard VGA defined by IBM, for example text modes with 132
  177. characters on each line, or graphics resolutions of 800x600, 1280x1024
  178. and more.  Such cards are usually referred to as Super VGAs.  To make it
  179. possible to produce such resolutions, video card developers has had to
  180. add new registers to the set of registers defined by the VGA.  TWEAK is
  181. generally not able to support such extended registers, meaning that you
  182. will not be able to tweak a Super VGA any more than is possible on a
  183. standard VGA.  Extensions that are provided by utilizing undefined bits
  184. in the standard VGA registers are supported however.  The included
  185. Chips & Technologies specific 132x*.twk files are examples of such.
  186.  
  187. The main reason for not including Super VGA (SVGA) support is that
  188. there are so many different SVGA standards.  Nearly every developer has
  189. their own standard.  Also, I can see no real reason for wanting to tweak
  190. any SVGAs, as the resolution dimensions they offer usually are far
  191. superior to the VGA's resolutions.  With tweaked VGA modes there's
  192. a much higher propability that they will work on most VGAs and SVGA,
  193. than tweaked SVGA modes.
  194.  
  195. If this is the first you have read about VGA registers and the BIOS,
  196. TWEAK.EXE and this documentation alone is not enough to get you going.
  197. You will need, and probably want, a somewhat technical reference to the
  198. VGA, which explains all standard VGA registers and the meaning of every
  199. contained bit.  Although TWEAK doesn't support it, you'll probably want
  200. a reference which also contains some discussion on Super VGAs, just for
  201. your convenience when you want to program serious applications etc.  If
  202. you're of the adventurous breed, check out the VGA.TXT and VGABIOS.TXT
  203. files included in the .\MISC directory.
  204.  
  205. You see, tweaking the VGA is not as simple as putting the horizontal
  206. resolution in one register, the vertical in another and the number of
  207. colours in yet another.  Several registers has to be set to cooperating
  208. values that work together to acheive what you want.  Single bits has to
  209. be toggled into the correct states, even before you can see anything on
  210. screen.  TWEAK simplifies this process by letting you do this
  211. interactively, and by letting you test your register set at the touch
  212. of one key (ENTER, actually).  The pre-TWEAK process was to make a small
  213. program that set up the registers in the way the programmer thought
  214. would work.  If it didn't he had to edit the program source file,
  215. recompile, and re-run.  Not seldom, the PC crashed because of some
  216. *really bad* register values, and a full reset was required.
  217.  
  218. TWEAK let you save and load register sets to and from files, and let
  219. you select any video mode supported by your BIOS to work out from.
  220. It supports text modes and graphics, 16-color and 256-color.  Monochrome
  221. modes and CGA modes (4- and 2-color), however, are not supported,
  222. because they use another set of I/O ports, and because few people are
  223. really interested in them.
  224.  
  225. As of version 1.6, TWEAK further simplifies the VGA tweaking process by 
  226. providing instant feedback on the register values, in the form of a 
  227. live mode heuristic, i.e. a detection scheme tried to figure out what 
  228. type of mode your making, the number of colors, its physical and 
  229. virtual resolution, the number of pages (both horizontally and 
  230. vertically).
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.                         A COUPLE OF RULES
  238.  
  239.  
  240. I'll be the first to admit:  TWEAK isn't much of an editor.  The screen
  241. is boring, there is just one simple help window, no undo command, no
  242. file pick lists etc.  In short, TWEAK is not meant for people not
  243. knowing what they are doing.  I strongly beleive that nothing can be
  244. damaged from the use of TWEAK, but for starters, I'll recommend the
  245. following precautions:
  246.  
  247.   *  When loading/saving, take care to check that you selected the
  248.      function (load or save) that you want, before typing a filename
  249.      and pressing Enter.  Also verify that the filename you type when
  250.      saving is the filename that you want, because TWEAK overwrites
  251.      any existing files with the same name without asking for permission.
  252.  
  253.   *  If, when you press the Enter screen to test the screen mode,
  254.      nothing appears after 5-10 seconds, press Enter again.  If you're
  255.      not immediately returned to the editing screen, reboot your
  256.      computer by pressing the reset button.  Keep in mind that some of
  257.      the test patterns, especially the 256-color 4-planar one, can be
  258.      slow to put into the video memory buffer, so be a *little*
  259.      patient & tolerant.
  260.  
  261. That last rule is present to prevent that the monitor is exposed to crazy
  262. sync timings for too long a time.  And I repeat, there usually never is
  263. any reason to panic, even if your monitor makes strange sounds
  264. ('tweeeeee' for example, or 'flick-flick-flick').  Press ENTER, wait for
  265. a couple of seconds more, then reset your computer if the edit screen
  266. doesn't reappear, and try a different approach.
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.                            A TUTORIAL
  274.  
  275.  
  276. To start TWEAK, change to the directory where you have put the files,
  277. and type TWEAK at the DOS prompt.  Well, now you're in the editor, and
  278. you can see the following things (you might want to print this tutorial
  279. so you have it on paper):
  280.  
  281.   *  One (possibly two) column(s) of VGA registers on the form:
  282.      ppp (ii)         Register Name : vv
  283.      where
  284.        -  ppp is the port number
  285.        -  ii is the index into that port, if applicable
  286.        -  vv is the selected value for this register
  287.      All numbers are hexadecimal.  The current register is marked by one
  288.      arrowhead on each side of the line.  When you first start TWEAK,
  289.      the current register is the top left.
  290.  
  291.   *  A bit pattern display showing the bit pattern of the 8-bit value
  292.      contained in the currently selected register.
  293.  
  294.   *  The bottom line tells you which test pattern is currently active.
  295.  
  296.   *  You will also see the mode heuristic which usually makes a good
  297.      guess at what mode you have at the moment.
  298.  
  299. When executed, TWEAK starts up by reading the registers of your current 
  300. BIOS mode, so that you have something to work with.  This is usually a 
  301. text mode, 80x25 for example, so you'll probably want to set a graphics 
  302. mode for more interesting results.
  303.  
  304. Now try the following simple tutorial:
  305.  
  306.   1. Press H, and a red window should appear, describing all keys
  307.      available for use in TWEAK.  These will also be described below.
  308.  
  309.   2. Press M, then type the number 03.  Notice that you don't have to
  310.      press ENTER.  You have now selected BIOS mode 3 as the basis for
  311.      you explorations.  Notice also the information provided by the 
  312.      mode heuristic on the right.
  313.  
  314.   3. Press TAB until 'Text screen, 16 point' appears at the bottom line,
  315.      if it doesn't already.  TAB selects which test pattern to use, and
  316.      you have now readied the 16-point font version of the text screen
  317.      test.
  318.  
  319.   4. Press ENTER.  You should see a screen with numbers along the top
  320.      row, and various characters and colors down the rest of the screen.
  321.      This is the text test pattern, as it looks when viewed in mode 3.
  322.      Press ENTER to return to editing mode.
  323.  
  324.   5. Now press F10, and type '40x12' and press ENTER.  This loads the
  325.      file '40x12' and uses its contents as the current register set.  
  326.      Notice how the mode heuristic immediately changes.
  327.  
  328.   6. Press ENTER again.  A screen similar to the previous test pattern
  329.      should appear, but the characters should be twice as wide and twice
  330.      as high.  This is a tweaked VGA mode, which is not supported by the
  331.      BIOS.  It looks a little odd, as the bottom line is cut in half,
  332.      making this a 40x12.5 text mode, in fact.  Press ENTER to return.
  333.  
  334.   7. Press F10, type '360x480.256' and ENTER.  Take a look at the 
  335.      mode heuristic again.  Press TAB until the text 'Graphics 
  336.      autodetect' appear in the bottom line.
  337.  
  338.   8. Press ENTER.  This is a well known tweaked VGA mode that has even
  339.      been used in commercial games for the PC, but it remains
  340.      unsupported by the BIOS (and it probably always will).  If the
  341.      screen rolls, try adjusting your monitor knobs.  If you can't get a
  342.      steady picture, it probably means your monitor isn't capable of
  343.      handling the horizontal resolution of 360 pixels.
  344.  
  345.   9. Try using the arrows to scroll the virtual screen.
  346.  
  347.   9. Press ENTER to return to editing, then press ESC and 'Y' to quit 
  348.      TWEAK.
  349.  
  350.  
  351. The last graphics display might not have been especially pleasing to the
  352. eye.  First, if the picture was rolling uncontrollably, you might think
  353. that TWEAK is of no use for you, as your monitor isn't good enough.
  354. However there are still interesting things to try out.  There are
  355. tweaked modes 'available' with a little lower resolution that are almost
  356. guaranteed to work on your monitor, and which are of great interest to
  357. games programmers for example.  The file 320x240.256 contains the
  358. register set for the infamous Mode X, which was 'discovered' and
  359. documented by Michael Abrash in his monthly columns in Doctor Dobbs
  360. Journal.
  361.  
  362. Following points 7 onward above, see if you can load Mode X into the 
  363. editor and get the test screen going!
  364.  
  365. Mode X has the following interesting properties:
  366.  
  367.   *  The pixels are 'perfectly' square.  That is, if you try to draw a
  368.      circle with aspect ratio 1:1, it will look like a circle (unless
  369.      your monitor is adjusted to some extreme).  The BIOS mode 13h
  370.      (320x200x256) has pixels that are a little higher than they are
  371.      wide, making 1:1 circles look stretched vertically.
  372.  
  373.   *  The video memory is divided into 4 planes, each of which contains
  374.      64 Kb.  By setting the Write Plane Enable register to the actual
  375.      plane, you can address the full 256 Kb of video memory through the
  376.      'tiny' address space of 64 Kb from 0xA000:0 to 0xA000:0xFFFF.
  377.      Thus, you can have more than three full screens in video memory at
  378.      any one time, making you able to perform animation tricks as
  379.      page flipping, and to do fast 32-bit video to video transfers.
  380.  
  381. This was just to get you going, and others have written tons of text on
  382. drawing stuff (lines, circles, images) in Mode X.  The rest of this
  383. part will deal with the commands available in TWEAK.  To get more
  384. information about VGA programming in general and registers and Mode X 
  385. in particular, check out the reference list somewhere at the end.
  386.  
  387. Stop press!  Read the article in the XINTRO subdirectory for an
  388. introduction to Mode X.
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                          EDITOR REFERENCE
  395.  
  396.  
  397. This reference applies only to version 1.0 of TWEAK or later, although
  398. *most* keys are supported by the included version 0.95 too.
  399.  
  400. Select the register value you want to modify using the following keys:
  401.  
  402.      Up         selects previous register
  403.      Down       selects next register
  404.      Home       selects first register
  405.      End        selects last register
  406.  
  407. Use these keys to modify a register value:
  408.  
  409.      a 2-digit, hexadecimal number : sets the register to the given value
  410.      '-'        decreases the value of the register
  411.      '+'        increases the value of the register
  412.      F1 ... F8  toggle bits 7, 6, ..., 0 of the selected register,
  413.                 respectively.
  414.  
  415. Use these keys for testing the set of register values:
  416.  
  417.      TAB [->|]  cycle among the available test patterns, to find the
  418.                 one you think will suit your custom register set.
  419.                 Shift+TAB cycles in the opposite direction.
  420.  
  421.      ENTER      sends your custom register set to the VGA registers, then
  422.                 writes the selected test pattern to the video memory buffer.
  423.  
  424. Some other important or useful actions:
  425.  
  426.      Backspace  toggles the active state of the current register.  If a
  427.                 register is inactive, it color is grey instead of yellow.
  428.                 When you test the mode (by pressing ENTER), inactive
  429.                 registers will *not* be sent to the VGA card.  Also, they
  430.                 will *not* be saved to the file when a Save command is
  431.                 executed.  This feature is included to enable you to ignore
  432.                 registers that doesn't affect your screen mode.  For
  433.                 example, for most practical uses, the Color Compare register
  434.                 can be deactivated.
  435.  
  436.      'M'        prompts the user for a 2-digit, hexadecimal number
  437.                 specifying a standard VGA BIOS screen mode number.  Note
  438.                 that TWEAK does *not* support true monochrome modes.
  439.                 The VGA is set to this mode using INT 10h with AX=mode
  440.                 number.  Then all relevant registers are read from the
  441.                 VGA into the editing set, and you're returned to the
  442.                 editing screen.
  443.  
  444.      F9 or 'S'  prompts the user for a file name, then saves the register
  445.                 set to this file, overwriting any pre-existing
  446.                 file by the same name.  Inactive registers are not saved,
  447.                 thus there are no longer a fixed size to TWEAK's mode
  448.                 files.
  449.  
  450.      F10 or 'L' prompts the user for a file name, then loads the register
  451.                 set from this file, if it exists.  Registers that are
  452.                 supported by TWEAK, but that are not included in the file,
  453.                 will be deactivated (greyed).
  454.  
  455.      ESC        quits TWEAK, if you answer 'y' or 'Y' to the 'Really
  456.              quit?' question.  Make sure you have saved your work.
  457.  
  458. Pressing just ENTER at one of the two file name requests will cancel 
  459. the file operation.
  460.  
  461.  
  462. There are currently 6 available test screens with TWEAK.  Numbers in
  463. parentheses are all the standard VGA BIOS modes that display the test
  464. patterns correctly:
  465.  
  466.   o  An autodetected graphics screen test.  This will detect *most*
  467.      EGA and VGA graphics modes (of course no monochrome modes), and
  468.      display a pretty screen containing:
  469.  
  470.      -  axes along the left and top borders visualizing the resolution.
  471.      -  text telling you both the physical and the virtual resolutions,
  472.         and the number of colors.
  473.      -  the entire palette available in this mode.  Note that the
  474.         palette is *not* set, so the colours are not guaranteed to be
  475.         the normal VGA palette, except in 16-color mode.
  476.  
  477.      The following keys are available in the autodetect test screen:
  478.  
  479.      -  arrows scroll the screen across the virtual area
  480.      -  ESC returns to the editor
  481.  
  482.      If the mode being edited is not a graphics mode, a text screen
  483.      appears with some helping hints.
  484.  
  485.   o  2 text test screens at 0B800h
  486.      -  one using the normal 8x16-point VGA font (0, 1, 2, 3)
  487.      -  one using the 8x8-point CGA font (normally used in 43/50-line
  488.         modes, but none of those are defined by the VGA BIOS.  Check
  489.         VGABIOS.DOC for the function to load a specific font in your 
  490.     own programs.)
  491.  
  492.   o  A screen for 4-planar, 16-color modes at 0A000h (0Dh, 0Eh, 10h,
  493.      12h)
  494.  
  495.   o  A screen for 4-chained, 256-color modes at 0A000h (13h)
  496.  
  497.   o  A screen for 4-planar, 256-color modes at 0A000h (None supported
  498.      by BIOS)
  499.  
  500. See the source (TESTPAT.CPP) for descriptions on how the test patterns are
  501. supposed to look.  Generally, if it looks good, it should be correct.
  502.  
  503.  
  504.  
  505.  
  506.  
  507.                     FREQUENTLY ASKED QUESTIONS
  508.  
  509.  
  510. Q:      I'd like to study the register configuration for a screen mode
  511.         supported by my (Super-)VGA.  How do I get to it?
  512.  
  513. A:      The 'M' key lets you select a BIOS mode to study.  Note that you
  514.         will need to know the mode number.  Note that TWEAK does not 
  515.     support any SVGA-specific registers.
  516.  
  517.  
  518. Q:      None of the tests seem to produce sane results.  The screen
  519.         a) goes black,
  520.         b) rolls or
  521.         c) the program crashes.
  522.  
  523. A:      a)  - Make sure you tried ALL 5 tests.
  524.             - Set the Color Plane Write Enable register to 0Fh.
  525.             - Note that Super VGA modes are generally not supported
  526.               (though they *might* work).
  527.         b)  - The timing/sync registers are not set correctly/in sync.
  528.               See your VGA reference for more information.
  529.             - Try adjusting the knobs on your monitor.
  530.     c)  - I know some (S)VGAs completely hang the system if
  531.           unsupported bit combinations are fed into the Misc.
  532.           Output Register (0x3c2).  This is one of the most useful
  533.           registers, however, so experiment with care, and take note
  534.           of what values causes the crash.
  535.             - You may have hit a major incompatibility/bug.  Send me a
  536.               mail, telling me what kind of hardware you're using.  I
  537.               will probably not be able to fix it, but an incompatibility
  538.               list will be emitted with the next release, if any.
  539.  
  540.  
  541. Q:      How about a TSR to save the current register configuration from
  542.         any program?
  543.  
  544. A:      I've considered this, but haven't had the time.  A hint, though:
  545.         Get CBOOTxxx.ZIP from simtel or any mirror, in .../msdos/sysutl.
  546.         This program lets you break out from most applications,
  547.         *without* resetting the screen mode.  A typical session:
  548.             - Install CBOOT.
  549.             - Run FRACTINT (a fractal explorer package, supporting lots
  550.               of tweaked modes), and select the mode you want to 'grab'.
  551.             - Press ALT+SHIFT+B, and the CBOOT menu pops up.
  552.             - Press '7' to reset interrupt vectors.
  553.             - Press '6' to 'properly' exit from FRACTINT.
  554.             - You might not see it, but you should be at the DOS prompt.
  555.             - Run TWEAK directly, which will start up with the current
  556.               register configuration.  Now you're off!
  557.     From programs (games) which assume total keyboard domination, I
  558.     currently cannot help you grab modes.
  559.  
  560.  
  561. Q:      I'd like to use tweaked modes in my own programs.
  562.  
  563. A:      Provided you have produced TWEAK files corresponding to your
  564.         modes, take a look at the example files for different approaches
  565.         to using the mode files.  The examples are in C, but are simple
  566.         enough, so translation to Pascal should be a breeze.
  567.  
  568.  
  569. Q:      - What is the register which makes x do y/sets a to b/etc.?
  570.         - Is there a BIOS call to do x?
  571.  
  572. A:      First check the VGA.TXT and VGABIOS.TXT files in the MISC
  573.         directory.  If they don't help you, please consider buying a
  574.         technical reference to the VGA.  That would please you and me.
  575.  
  576.  
  577. Q:      How do I make a mode with resolution x times y with z colors?
  578.  
  579. A:      - See the sample *.TWK, *.256 and *.16 files provided with
  580.           TWEAK.  Not a great lot, but you might be able to work out
  581.           something from one of those.
  582.         - Get FRACTINT or SVGABGI, and use the method mentioned above to
  583.           'grab' modes from these programs.
  584.     - Learn what each of the VGA timing registers means.
  585.         - Experiment!  That's what I had to do.
  586.  
  587.  
  588. Q:      I can't find this MISC or XINTRO directory!
  589.  
  590. A:      Make sure you unzip the TWEAK archive with the -d option, which
  591.         is needed to extract subdirectories.  I.e:
  592.           PKUNZIP -D A:TWEAK10
  593.     If you didn't use -D, the files in the MISC directory are mixed
  594.     in with the rest of the TWEAK package files, all in the same
  595.     directory.
  596.  
  597.  
  598. Q:      I have lots of files with modes that I saved with version 0.9 of
  599.         TWEAK...
  600.  
  601. A:      Use the 09TO10 utility to convert them.  Run 09TO10.EXE with no
  602.         parameters for a simple help screen.
  603.  
  604.  
  605. Q:      What do I need to rebuild TWEAK and/or the utilities?
  606.  
  607. A:      You will need Borland C++.  I used version 3.1, but it might
  608.         work as far back as Turbo C++ 1.0.  I included a Makefile to
  609.         make rebuilding as painless as possible, provided you have
  610.         BCC.EXE in your path, and it knows where to find headers and
  611.         libraries (usually it does).  I know some of the sources
  612.     produce warnings, but feel free to ignore them.  I did.
  613.  
  614.  
  615. Q:      What do I need to use the mode files produced by TWEAK in my own
  616.         programs?
  617.  
  618. A:      If you want to use the TwkUser module, you'll need a C compiler.
  619.         I don't think I used anything Borland specific here.
  620.         Otherwise the file format is pretty simple, so you should have
  621.         no problem making similar functions/procedures using any
  622.         language (assembler, Basic, Pascal, Prolog...).
  623.  
  624.  
  625. Q:      Where can I find more information on tweaking the VGA?
  626.  
  627. A:      See the Bibliography section below.  Michael Abrash's articles
  628.         in Doctor Dobb's Journal from a year or so are probably the best
  629.         sources.  Join the rec.games.programmer newsgroup.  There has
  630.         been some discussion on tweaking there, especially mode X
  631.     (320x240x256) and how to optimize code for this mode.
  632.  
  633.  
  634. Q:      How can I ever repay you for making such a great utility?
  635.  
  636. A:      Easy!  The cheapest way is to send me a cool postcard with some
  637.         (readable) words on it.  I will of course accept donations too,
  638.         even though TWEAK is public domain.  See the end of this file.
  639.  
  640.  
  641. Q:      PKUNZIP refused to unzip the TWEAK archive!
  642.  
  643. A:      I guess you decoded this DOC file by hand, then...  well, make
  644.         sure you transfer in BINARY mode from the ftp site, and in 
  645.     BINARY from your user account to your PC.
  646.  
  647.  
  648. Q:      I can't find my question in the Frequently Asked Questions list!
  649.         Does this mean I'm stupid?
  650.  
  651. A:      It might.  :-)  However, I just thought up all these questions
  652.         myself, so if you have a suggestion for more FAQs, don't
  653.         hesitate to let me know!  I promise I won't laugh...
  654.  
  655.  
  656. Q:    The mode heuristic tells me I have the mode I want, but none of 
  657.     the test screens works, not even the autodetecting one!
  658.  
  659. A:    The heuristic is far from perfect.  It does NOT verify that the 
  660.     timing values you are using are sane - it merely checks the 
  661.     registers determining the logical resolutions.  The best advice 
  662.     I can give is to get a VGA reference and try to learn what the 
  663.     horizontal and vertical timing registers do.  TWEAK is less 
  664.     intelligent than you (hopefully)!
  665.  
  666.  
  667.  
  668.  
  669.                         THE TWEAK FILES
  670.  
  671.  
  672. The file format used for saved files is pretty simple.  The files will
  673. usually be bigger than the files saved with TWEAK 0.9, and version 0.9
  674. files are *not* readable by version 1.0.  This is undetectable by TWEAK,
  675. because of the simple nature of the files.  (No headers are present!) 
  676. If you try, there's a fat chance that your computer will hang.
  677.  
  678. Here is the format:
  679.  
  680. offset 0: WORD - port number of first register
  681. offset 2: BYTE - index of first register
  682. offset 3: BYTE - value of first register
  683.  
  684. offset 4: WORD - port number of second register
  685. .
  686. .etc.
  687. .
  688.  
  689. Pretty simple, as you can see, but also flexible from TWEAK's point of
  690. view.  This makes it easy to add new ports if neccessary.  The file size
  691. is not constant, as registers that are disabled at save time are not
  692. written to the file.  Divide the file size by 4 to determine the number
  693. of registers in a file, or just read to EOF (as TWEAK does... :).
  694.  
  695. Also note that the VGA registers use varying methods for access.  For
  696. some registers you just send the value directly to the port (ignoring the
  697. index).  For some you send the index to the port, then the value to the
  698. port+1.  For still some you have to ...  Rather, refer to the source
  699. code for all the how-to's...  it's not difficult, just inconvenient, and
  700. it hinders really general storage of register addresses and their values.
  701.  
  702. Use the 09TO10.EXE program to convert from version 0.9 files to version
  703. 1.0 files.  Run 09TO10.EXE with no parameters for information on how to
  704. use the utility.
  705.  
  706. I have selected the following standard of file extensions for
  707. TWEAK-files, but these are just suggestions for my own convenience:
  708.  
  709.   o  *.TWK are text modes
  710.   o  *.16 are 16-color graphic modes
  711.   o  *.256 are 256-color graphic modes
  712.  
  713. Note that you'll always have to type an extension in TWEAK if you want
  714. any, as TWEAK neither assumes anything nor provides default extensions.
  715.  
  716. I have also started addint a 'c' to the name (like in 256x256c.256) if 
  717. the mode is chained, i.e. uses linear addressing like mode 13h.  I add 
  718. an 's' if the mode is specific to my Chips & Technologies SVGA.
  719.  
  720. Make sure you read MODES.DOC!
  721.  
  722.  
  723.  
  724.  
  725.  
  726.                   USING TWEAK MODES ON YOUR OWN
  727.  
  728.  
  729. The Register and RegisterTable classes used in TWEAK.CPP might be a
  730. little huge and clumsy to use in your own programs, where you probably
  731. just want to set the registers according to a linked-in array.
  732. Therefore I have provided a simple C module for the following functions:
  733.  
  734.   o  Reading a file saved from TWEAK into a dynamically allocated
  735.      array of registers.
  736.   o  Setting VGA registers according to the contents of an array of
  737.      registers.
  738.   o  Setting a single register.
  739.  
  740. The types and functions are declared in TWKUSER.H, which should be
  741. included in every source file using these functions.  The definitions
  742. are contained in TWKUSER.C, which should be compiled under the wanted
  743. memory model and linked together with your program modules.  You are
  744. free, in fact you're encouraged to modify the TWKUSER files to suit
  745. your own needs.  In their present form, they just provide enough
  746. functionality to get you started.
  747.  
  748. A couple of simple examples are provided - the second one is easiest to
  749. follow, and I think you will prefer that one:
  750.  
  751.   o  EXAMPLE1.C - demonstrates how to use a TWEAK-generated file
  752.      in your own program by loading the file at run-time, and setting 
  753.      the VGA registers according to the file contents.  The mode file 
  754.      has to be available at run-time.
  755.  
  756.   o  EXAMPLE2.C - does the same, but now the TWEAK-file is converted to
  757.      a C-includable file by using the TWEAK2C utility.  Thus, the contents
  758.      of the TWEAK file is linked with the program as global data, and no
  759.      external file is needed in addition to the executable.
  760.  
  761. Both programs set the VGA to the famous Mode X, 320x240 in 256 colors,
  762. then fill the screen with some colors.
  763.  
  764. Note that since the files produced by TWEAK does not keep any 
  765. information on what BIOS mode they are based on, you are responsible 
  766. for setting the palette used.  Keep in mind that you need to set both 
  767. the EGA and VGA palette for 256-color modes!  The easiest way to 
  768. accomplish this is to set mode 13h before outputting your register 
  769. settings.
  770.  
  771. I would very much like to provide similar Borland Pascal examples, but
  772. as I don't have Turbo/Borland Pascal available at the moment, I'm just
  773. going to skip it at this time.  If *you* feel like porting the TwkUser.C
  774. and .H files to a Pascal unit, please do.  It should be a peice of cake.
  775. If you mail the result to me, I'll probably include it in the next release
  776. of TWEAK, and in any case you'll be credited for your contribution.
  777.  
  778.  
  779.  
  780.  
  781.  
  782.                       THE INCLUDED FILES
  783.  
  784.  
  785. This is a dump of the 4DOS compatible DESCRIPT.ION file included in this
  786. archive:
  787.  
  788. 320x200.256 Planar 320x200x256
  789. 320x240.256 Planar 320x240x256 (Mode X)
  790. 360x480.256 Planar 360x480x256
  791. 400x300s.256 Tweaked C&T SVGA planar
  792. 400x600.256 Tweaked VGA, req. good monitor
  793. 400x600s.256 Tweaked C&T SVGA planar
  794. 432x600s.256 Tweaked C&T SVGA planar
  795. 800x600s.16 Standard C&T SVGA BIOS mode
  796. 40x12.twk Standard VGA BIOS mode 1, double scanned
  797. 80x43.twk Standard VGA mode, needs 8x8 font
  798. 80x50.twk Standard VGA mode, needs 8x8 font
  799. 09to10.cpp Version 0.9x to 1.0 conv. util. source
  800. 800x600.16 Tweaked VGA, req. good monitor
  801. example1.c C source for EXAMPLE1.EXE
  802. example2.c C source for EXAMPLE2.EXE
  803. makefile Type MAKE ALL to update TWEAK project
  804. namedreg.cpp C++ source defining NamedReg. members
  805. register.hpp C++ header declaring Register & NamedReg
  806. regtable.cpp C++ source defining RegisterTable
  807. regtable.hpp C++ header declaring RegisterTable
  808. screen.cpp C++ source defining screen functions
  809. screen.hpp C++ header declaring screen functions
  810. tweak.cpp C++ source defining TWEAK's main program
  811. tweak.doc Documentation for the TWEAK archive
  812. tweak2c.cpp C++ source for the TWEAK2C utility
  813. twkuser.c C source defining som usable functions
  814. twkuser.h C header with TwkUser.C prototypes
  815. register.cpp C++ source defining Register members
  816. 320x240.c C file created by TWEAK2C
  817. c&t.dat Text file: list of supported registers
  818. 256x256.256 Planar 256x256x256 (Mode Q)
  819. 256x256c.256 Chained 256x256x256 (Mode Q, chained)
  820. testpat.cpp C++ source defining TestPatterns members
  821. testpat.hpp C++ header declaring TestPatterns
  822. 256x240.256 Planar 256x240x256
  823. 360x270.256 Experimental mode
  824. 400x300.256 Planar 400x300x256 - great!
  825. detect.cpp C++ source for mode detected module
  826. detect.hpp C++ header for detect.cpp
  827. misc.hpp Various common routines and macros
  828. tweak095.cpp C++ source for TWEAK version 0.95
  829. vgalib.cpp The mode-independant VGA library source
  830. vgalib.hpp Header for VGALIB.HPP
  831. regedit.cpp C++ source for the RegisterEditor class
  832. regedit.hpp C++ header for REGEDIT.CPP
  833. descript.ion Descriptions of all files
  834. tweak.prj TWEAK archive BC++ 3.1 project file
  835. 320x400.256 Planar 320x400x256
  836. 360x360.256 Planar 360x360x256
  837. 360x400.256 Planar 360x400x256
  838. 376x564.256 Planar 376x564x256
  839. tweakold.dat Data file: list of supported registers
  840. 132x25s.twk Standard C&T SVGA BIOS mode
  841. 132x43s.twk Standard C&T SVGA BIOS mode
  842. 132x50s.twk Standard C&T SVGA BIOS mode
  843. 132x60s.twk Ultravision C&T SVGA mode
  844. modes.doc Document on Mode Q, 400x300 and 400x600
  845.  
  846. The only files required to run TWEAK are:
  847.  
  848.   o  TWEAK.EXE
  849.   o  TWEAK.DAT
  850.  
  851. The register definitions have been moved out from the executable into
  852. the external .DAT file, to increase flexibility.  You might edit the
  853. TWEAK.DAT file as you like to include support for any registers you
  854. might think of.  Remember to update the number in the first line to
  855. reflect the number of defined registers.  Note that if your new registers
  856. are not on one of the ports supported by TWEAK.EXE, you might need to
  857. modify and recompile the TWEAK sources to accomodate the new port(s).
  858. See REGISTER.CPP.
  859.  
  860.  
  861.  
  862. Some words on my convention of naming files made by TWEAK:
  863. ----------------------------------------------------------
  864.  
  865.   o  The general name format is XXXxYYY.CCC, where
  866.         XXX is the horizontal resolution
  867.         YYY is the vertical resolution
  868.         CCC is the number of colors supported, except for text modes,
  869.             which are named *.TWK.
  870.   o  An 's' after YYY specifies a Super VGA specific mode which I grabbed
  871.      from the BIOS of my Chips & Technologies Super VGA.  These modes will
  872.      probably *not* work with your card unless it's C&T compatible!  I've
  873.      had reports that most of these modes even crash some sensitive
  874.      machines/VGA cards.
  875.   o  A 'c' signals a chained 256-color mode, much like mode 13h, as 
  876.      opposed to unchained modes like mode X.
  877.  
  878.  
  879. The Makefile & sources
  880. ----------------------
  881.  
  882. See the Makefile for all dependencies between the source files.  It's not
  883. very complicated.
  884.  
  885. The following makes are defined in the Makefile:
  886.  
  887. make tweak: makes the TWEAK executable.
  888. make oldtweak: makes the TWEAK095 executable.
  889. make examples: makes EXAMPLE*.EXE.
  890. make utilities: makes 09TO10.EXE and TWEAK2C.EXE.
  891. make all: combines all the above makes.
  892.  
  893. The Makefile is Borland C++/MAKE specific, and uses bcc.exe for all the
  894. work, with one reference to TWEAK2C.EXE.
  895.  
  896. When studying the sources, note that TWEAK was started as an experiment
  897. in object oriented programming with C++.  Thus the entire project may look
  898. a bit pompous in its use of classes, overloaded operators and such.
  899. Bear with me.  At last I provided the TwkUser files to help you get
  900. started with something down to earth.
  901.  
  902. In their current state, some of the source files produce a couple of
  903. warnings.  These can be ignored.  I do.
  904.  
  905. Also note that TwkUser.* and the examples are C (but C++ compatible),
  906. while TWEAK and its utilities are strictly C++.
  907.  
  908.  
  909. The utilities TWEAK2C and 09TO10
  910. --------------------------------
  911.  
  912. The following are dumps of the help screens from there programs:
  913.  
  914. "TWEAK2C version 1.0
  915.  by Robert Schmidt of Ztiff Zox Softwear 1993
  916.  Converts a TWEAK version 1.x file to an #include-able C file.
  917.  
  918.  Syntax:  TWEAK2C <TWEAK-file> <C file to create> <array name>
  919.  All parameters are required."
  920.  
  921. "09TO10 version 1.0
  922.  by Robert Schmidt of Ztiff Zox Softwear 1993
  923.  
  924.  Converts TWEAK version 0.9 files to TWEAK version 1.0 files.
  925.  
  926.  Syntax:  09TO10 <oldfile> <newfile>"
  927.  
  928. For both programs, the following goes:  If the file to be created already
  929. exists, the data contained in the file on disk will be overwritten with the
  930. new data.
  931.  
  932.  
  933.  
  934.  
  935.  
  936.                       THE 'MISC' DIRECTORY
  937.  
  938.  
  939. In this directory I have included files from other sources than myself.
  940.  
  941. READ.ME
  942. VGA.TXT
  943. VGABIOS.TXT
  944.         I found these files in an archive assembled by Finn Thoegersen
  945.         of Denmark.  I beleive VGABIOS.DOC was taken from Ralph Brown's
  946.         interrupt list.  VGA.TXT lists VGA registers and their purpose,
  947.         but as I never used either VGA.TXT or VGABIOS.TXT, I can't
  948.         guarantee their correctness.  The complete archive containing
  949.         similar info on most popular Super VGAs can be found on
  950.         garbo.uwasa.fi in /pc/doc-hard/vgadoc2.zip.
  951.  
  952. CGA160.TXT
  953.         A post grabbed from some newsgroup, discussing tweaking on the
  954.         ancient CGA adapter.  I think 16-color 'graphics' on a CGA
  955.         sounds pretty interesting, so I included it for your enjoyment.
  956.  
  957. SETMODEX.ASM
  958.         Michael Abrash's code to set the VGA in the infamous Mode X.
  959.         Provided as an example of how programmers were used to tweaking,
  960.         before TWEAK came along... :)
  961.  
  962.  
  963.  
  964.  
  965.  
  966.                            CREDITS
  967.  
  968. Alphabetically:
  969.  
  970.   o  Michael Abrash for doing so much work on Mode X and PC graphics in
  971.      general.
  972.   o  Ralph Brown for the great work on the Interrupt List.
  973.   o  Peter McDermott for an improved 16-color test screen, and valuable
  974.      sugestions, he also inspired me to make the autodetecting test
  975.      screen.
  976.   o  Kai Rohrbacher for helpful bug reports and info on working modes.
  977.   o  Finn Thoegersen for the MISC\VGA*.TXT files.  See MISC\READ.ME
  978.   o  Yaniv Shaya for inspiring me to make finish version 1.0.  Good luck
  979.      with your project!
  980.  
  981.  
  982.  
  983.  
  984.  
  985.                          BIBLIOGRAPHY
  986.  
  987.   o  George Sutty & Steve Blair : "Advanced Pogrammer's Guide to the
  988.      EGA/VGA" from Brady.  A bit old perhaps, but covers all *standard*
  989.      EGA/VGA registers, and discusses most BIOS functions and other
  990.      operations.  Contains disk with C/Pascal source code.
  991.  
  992.   o  Michael Abrash : "Power Graphics Programming" from QUE/Programmer's
  993.      Journal.  Collections of (old) articles in Doctor Dobb's Journal on
  994.      EGA/VGA, read modes and write modes, animation, tweaking (320x240
  995.      and 360x480).  His newer ravings in DDJ covers fast 256-color
  996.      bitmaps, compiled bitmaps, 3D graphics, polygons, texture mapping
  997.      among other stuff.  Check out the XSHARP library available on all
  998.      simtel mirrors!
  999.  
  1000.   o  Ralph Brown's interrupt list is a must for every serious
  1001.      programmer, containing, among 1 million other things, a VGA BIOS
  1002.      interrupt reference.  Available for anonymous ftp from
  1003.      oak.oakland.edu in directory /pub/msdos/info as inter*.zip (Usually
  1004.      3 files, around 330 Kb each), and on most serious BBSes.
  1005.  
  1006.   o  Richard F. Ferraro : "Programmer's Guide to the EGA and VGA video
  1007.      cards including Super VGA".  I don't have this one, but heard it's
  1008.      nice.  The Super VGA reference makes it attractive, though that is
  1009.      no help with TWEAK.
  1010.  
  1011.   o  Richard Wilton : "Programmer's Guide to PC & PS/2 Video Systems"
  1012.      Less technical, more application/algorithm oriented.  Supposed to be
  1013.      good.
  1014.  
  1015.  
  1016.  
  1017.  
  1018.                         HOW TO REACH ME
  1019.  
  1020.  
  1021. I welcome any suggestions for further improvement of TWEAK.  I also
  1022. accept donations if you think it's worth it, or if TWEAK has in any way
  1023. helped you out with a tricky problem and you'd like to show your
  1024. appreciation.  I will personally e-mail subsequent versions to people who
  1025. donate $5 or more.  Make checks payable to Robert Schmidt personally.
  1026.  
  1027. Postcards from all over the world are fun to get.  Please, if you
  1028. contact me by ordinary mail, use a postcard with some photos from the
  1029. place you live on the front!  I appreciate that a lot.
  1030.  
  1031.  
  1032.  
  1033. Internet e-mail: robert@stud.unit.no
  1034.  
  1035. (I guess this should be reachable from Compuserve and other networks
  1036. too.  I don't know how, though.)
  1037.  
  1038. If you ever join the IRC service on the Internet, direct a /msg Buuud
  1039. for a chat!  I'm on pretty often.
  1040.  
  1041.  
  1042.  
  1043. Ordinary (snail-)mail:
  1044.  
  1045. Ztiff Zox Softwear
  1046. c/o Robert Schmidt
  1047. Stud.post 170
  1048. Norwegian Institute of Technology
  1049. Trondheim
  1050. NORWAY
  1051.  
  1052.  
  1053. Good luck, and remember the most important bit is to have fun!
  1054.  
  1055.